var treeGrid;
var pathName = window.document.location.pathname;
//获取带"/"的项目名
var ctx = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);

$(function() {
	$('#parentPurId').combotree({
		url : ctx+'/purview/getTree',
		parentField : 'pid',
		lines : true,
		panelHeight : 'auto'
	});
	$("#parentPurId").combotree('setValue',1);
	$('#purViewAddForm').form({
		url : ctx+'/purview/addPurView',
		onSubmit : function() {
			progressLoad();
			var isValid = $(this).form('validate');
			if (!isValid) {
				progressClose();
			}
			return isValid;
		},
		success : function(result) {
			progressClose();
			if (result=='添加成功') {
				parent.show("添加成功，请在角色管理界面重新为当前角色授权！","提示");
				parent.$.modalDialog.openner_treeGrid.treegrid('reload');//之所以能在这里调用到parent.$.modalDialog.openner_treeGrid这个对象，是因为pueViewList.jsp页面预定义好了
				//parent.layout_west_tree.tree('reload');
				parent.$.modalDialog.handler.dialog('close');
				//parent.location.reload();
			}else{
				parent.$.messager.alert('错误', result, 'error');
			}
		}
	});
});
